<template>
	<view class="container">
		<u-tabs class="tabs" :list="tablist" :is-scroll="true" :current="current" @change="change" active-color="#AB61FF"></u-tabs>
		
		<view class="u-flex u-row-center u-m-50" v-if="list.length == 0" style="flex-direction: column;">
			<image style="width:300rpx;height:300rpx;" mode="widthFix" src="../../../static/img/noc.png"></image>
			<text style="color:#ccc">暂无收藏</text>
		</view>
		<view class="list">
			<view class="item" v-for="(item,index) in list" :key="index" @click="handleClickItem(item)">
				<view class="left">
					<view class="item-cell">
						<text class="title">需要</text>
						<text class="value u-line-1">{{item.ineed}}</text>
					</view>
					<view class="item-cell">
						<text class="title">意向</text>
						<text class="value u-line-1">{{item.imean}}</text>
					</view>
					<view class="item-cell">
						<view class="text u-line-1">{{item.userName}}</view>
					</view>
				</view>
			</view>
			<u-toast ref="uToast" />
			<u-loadmore class="u-m-t-40" v-if="list.length == 3" :status="loadStatus" bg-color="#F5F5F9"></u-loadmore>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tablist: [],
				current: 0,
				tabbar: [{
						"name": "智汇团队",
						"foods": [],
						"type": '4'
					},
					{
						"name": "智汇N+1",
						"foods": [],
						"type": '9'
					},
					{
						"name": "智汇公社",
						"foods": [],
						"type": '8'
					},
					{
						"name": "工程信息",
						"foods": [],
						"type": '12'
					},
					{
						"name": "招聘",
						"foods": [],
						"type": '2'
					},
					{
						"name": "应聘",
						"foods": [],
						"type": '3'
					},
					{
						"name": "智汇信息",
						"foods": [],
						"type": '10'
					},
					{
						"name": "智汇推广",
						"foods": [],
						"type": '11'
					},
					{
						"name": "智汇活动",
						"foods": [],
						"type": '6'
					},
					{
						"name": "智汇学习",
						"foods": [],
						"type": '7'
					},
					{
						"name": "招投标",
						"foods": [],
						"type": '1'
					},
					{
						"name": "智汇服务",
						"foods": [],
						"type": '5'
					}
				],
				list: [],
				form: {
					pageNum: 1,
					pageSize: 10,
					type: '1'
				},
				loadStatus: 'loadmore'
			};
		},
		onPullDownRefresh: function() {
			this.form.pageNum = 1;
			this.getList();
			setTimeout(() => {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onReachBottom: function(e) {
			// 此tab为空数据
			this.form.pageNum += 1;
			this.loadStatus = "loading";
			this.getList(this.form.pageNum);
		},
		onLoad() {
			let that = this;
			this.tabbar.forEach(function(item) {
				that.tablist.push(item)
			})
			console.log(that.tablist)
			this.getList();
		},
		methods: {
			handleClickItem(item){
				console.log(item)
				uni.navigateTo({
					url:'/pages/follow/teamDetail?id='+item.businessId+'&type='+this.form.type+'&row='+encodeURIComponent(JSON.stringify(item))
				})
			},
			async getList(page) {
				let data = await this.$apis.businessCollections(this.form);
				if (data.data.length < this.form.pageSize) {
					this.loadStatus = "nomore";
				}
				if (page) {
					this.list = this.list.concat(data.data);
				} else {
					this.list = data.data;
				}
			},
			change(index) {
				this.current = index;
				this.form.pageNum = 1;
				this.form.pageSize = 10;
				this.form.type = index+1;
				this.getList();
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #F5F5F9;
	}

	.container {
		.tabs {}

		.list {
			width: 100%;
			padding: 20upx;

			.item {
				width: 100%;
				background: #fff;
				padding: 28upx;
				border-radius: 20upx;
				display: flex;
				justify-content: space-between;
				height: 206upx;
				margin-bottom: 20upx;

				.right {
					display: flex;
					flex-direction: column-reverse;

					image {
						width: 105upx;
						height: 96upx;
					}
				}

				.left {
					display: flex;
					flex-direction: column;
					justify-content: space-between;

					.item-cell {
						display: flex;
						justify-content: space-between;
						.title{
							width:100rpx;
							line-height: 30upx;
							height: 30upx;
							color: #9DA2B0;
							font-size: 30upx;
						}
						.value{
							flex:1;
							width:500rpx;
							line-height: 30upx;
							height: 30upx;
							color: #0D1D36;
							font-size: 30upx;
							margin-left: 30upx;
						}

						.text {
							color: #4B9CFF;
							font-size: 30upx;
						}
					}
				}
			}
		}
	}
</style>
